package fei.yuzhi.com.loveflowers.fragment.firstpagefragment.detail.baseinformation;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import fei.yuzhi.com.loveflowers.R;
import fei.yuzhi.com.loveflowers.bean.firstpagedetailbean.GoodsCommendListBean;

/**
 * Created by My on 2016/10/10.
 */
public class BaseInformationAdapter extends BaseAdapter {
    private Context context;
    private List<GoodsCommendListBean> commendListBeen;
    public BaseInformationAdapter(Context context,List<GoodsCommendListBean> commendListBeen){
        this.context=context;
        this.commendListBeen=commendListBeen;
    }
    @Override
    public int getCount() {
        return commendListBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return commendListBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_firstpage_baseinformation_gv,null);
            holder=new ViewHolder();
            holder.imageView= (ImageView) convertView.findViewById(R.id.item_first_base_goods_image);
            holder.goods_name= (TextView) convertView.findViewById(R.id.item_first_base_goods_name);
            holder.goods_price= (TextView) convertView.findViewById(R.id.item_first_base_goods_price);
            convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }
        Glide.with(context).load(commendListBeen.get(position).getGoods_image_url()).into(holder.imageView);
        holder.goods_name.setText(commendListBeen.get(position).getGoods_name());
        holder.goods_price.setText(commendListBeen.get(position).getGoods_price());
        return convertView;
    }
    static class ViewHolder{
        ImageView imageView;
        TextView goods_name,goods_price;
    }
}
